<?php


/**
 * Base class that represents a query for the 'user_pulpit' table.
 *
 *
 *
 * @method UserPulpitQuery orderByUserId($order = Criteria::ASC) Order by the user_id column
 * @method UserPulpitQuery orderByApplicationId($order = Criteria::ASC) Order by the application_id column
 * @method UserPulpitQuery orderBySize($order = Criteria::ASC) Order by the size column
 * @method UserPulpitQuery orderByDbOrder($order = Criteria::ASC) Order by the db_order column
 * @method UserPulpitQuery orderByBgFilename($order = Criteria::ASC) Order by the bg_filename column
 * @method UserPulpitQuery orderByVisible($order = Criteria::ASC) Order by the visible column
 * @method UserPulpitQuery orderByLastModified($order = Criteria::ASC) Order by the last_modified column
 * @method UserPulpitQuery orderByCreated($order = Criteria::ASC) Order by the created column
 *
 * @method UserPulpitQuery groupByUserId() Group by the user_id column
 * @method UserPulpitQuery groupByApplicationId() Group by the application_id column
 * @method UserPulpitQuery groupBySize() Group by the size column
 * @method UserPulpitQuery groupByDbOrder() Group by the db_order column
 * @method UserPulpitQuery groupByBgFilename() Group by the bg_filename column
 * @method UserPulpitQuery groupByVisible() Group by the visible column
 * @method UserPulpitQuery groupByLastModified() Group by the last_modified column
 * @method UserPulpitQuery groupByCreated() Group by the created column
 *
 * @method UserPulpitQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method UserPulpitQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method UserPulpitQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method UserPulpitQuery leftJoinApplications($relationAlias = null) Adds a LEFT JOIN clause to the query using the Applications relation
 * @method UserPulpitQuery rightJoinApplications($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Applications relation
 * @method UserPulpitQuery innerJoinApplications($relationAlias = null) Adds a INNER JOIN clause to the query using the Applications relation
 *
 * @method UserPulpitQuery leftJoinUsers($relationAlias = null) Adds a LEFT JOIN clause to the query using the Users relation
 * @method UserPulpitQuery rightJoinUsers($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Users relation
 * @method UserPulpitQuery innerJoinUsers($relationAlias = null) Adds a INNER JOIN clause to the query using the Users relation
 *
 * @method UserPulpit findOne(PropelPDO $con = null) Return the first UserPulpit matching the query
 * @method UserPulpit findOneOrCreate(PropelPDO $con = null) Return the first UserPulpit matching the query, or a new UserPulpit object populated from the query conditions when no match is found
 *
 * @method UserPulpit findOneByUserId(int $user_id) Return the first UserPulpit filtered by the user_id column
 * @method UserPulpit findOneByApplicationId(int $application_id) Return the first UserPulpit filtered by the application_id column
 * @method UserPulpit findOneBySize(int $size) Return the first UserPulpit filtered by the size column
 * @method UserPulpit findOneByDbOrder(int $db_order) Return the first UserPulpit filtered by the db_order column
 * @method UserPulpit findOneByBgFilename(string $bg_filename) Return the first UserPulpit filtered by the bg_filename column
 * @method UserPulpit findOneByVisible(int $visible) Return the first UserPulpit filtered by the visible column
 * @method UserPulpit findOneByLastModified(string $last_modified) Return the first UserPulpit filtered by the last_modified column
 * @method UserPulpit findOneByCreated(string $created) Return the first UserPulpit filtered by the created column
 *
 * @method array findByUserId(int $user_id) Return UserPulpit objects filtered by the user_id column
 * @method array findByApplicationId(int $application_id) Return UserPulpit objects filtered by the application_id column
 * @method array findBySize(int $size) Return UserPulpit objects filtered by the size column
 * @method array findByDbOrder(int $db_order) Return UserPulpit objects filtered by the db_order column
 * @method array findByBgFilename(string $bg_filename) Return UserPulpit objects filtered by the bg_filename column
 * @method array findByVisible(int $visible) Return UserPulpit objects filtered by the visible column
 * @method array findByLastModified(string $last_modified) Return UserPulpit objects filtered by the last_modified column
 * @method array findByCreated(string $created) Return UserPulpit objects filtered by the created column
 *
 * @package    propel.generator..om
 */
abstract class BaseUserPulpitQuery extends ModelCriteria
{
    /**
     * Initializes internal state of BaseUserPulpitQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_hr_app', $modelName = 'UserPulpit', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new UserPulpitQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     UserPulpitQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return UserPulpitQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof UserPulpitQuery) {
            return $criteria;
        }
        $query = new UserPulpitQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj = $c->findPk(array(12, 34), $con);
     * </code>
     *
     * @param array $key Primary key to use for the query
                         A Primary key composition: [$user_id, $application_id]
     * @param     PropelPDO $con an optional connection object
     *
     * @return   UserPulpit|UserPulpit[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = UserPulpitPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(UserPulpitPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   UserPulpit A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT USER_ID, APPLICATION_ID, SIZE, DB_ORDER, BG_FILENAME, VISIBLE, LAST_MODIFIED, CREATED FROM user_pulpit WHERE USER_ID = :p0 AND APPLICATION_ID = :p1';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
            $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new UserPulpit();
            $obj->hydrate($row);
            UserPulpitPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return UserPulpit|UserPulpit[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|UserPulpit[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {
        $this->addUsingAlias(UserPulpitPeer::USER_ID, $key[0], Criteria::EQUAL);
        $this->addUsingAlias(UserPulpitPeer::APPLICATION_ID, $key[1], Criteria::EQUAL);

        return $this;
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {
        if (empty($keys)) {
            return $this->add(null, '1<>1', Criteria::CUSTOM);
        }
        foreach ($keys as $key) {
            $cton0 = $this->getNewCriterion(UserPulpitPeer::USER_ID, $key[0], Criteria::EQUAL);
            $cton1 = $this->getNewCriterion(UserPulpitPeer::APPLICATION_ID, $key[1], Criteria::EQUAL);
            $cton0->addAnd($cton1);
            $this->addOr($cton0);
        }

        return $this;
    }

    /**
     * Filter the query on the user_id column
     *
     * Example usage:
     * <code>
     * $query->filterByUserId(1234); // WHERE user_id = 1234
     * $query->filterByUserId(array(12, 34)); // WHERE user_id IN (12, 34)
     * $query->filterByUserId(array('min' => 12)); // WHERE user_id > 12
     * </code>
     *
     * @see       filterByUsers()
     *
     * @param     mixed $userId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function filterByUserId($userId = null, $comparison = null)
    {
        if (is_array($userId) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(UserPulpitPeer::USER_ID, $userId, $comparison);
    }

    /**
     * Filter the query on the application_id column
     *
     * Example usage:
     * <code>
     * $query->filterByApplicationId(1234); // WHERE application_id = 1234
     * $query->filterByApplicationId(array(12, 34)); // WHERE application_id IN (12, 34)
     * $query->filterByApplicationId(array('min' => 12)); // WHERE application_id > 12
     * </code>
     *
     * @see       filterByApplications()
     *
     * @param     mixed $applicationId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function filterByApplicationId($applicationId = null, $comparison = null)
    {
        if (is_array($applicationId) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(UserPulpitPeer::APPLICATION_ID, $applicationId, $comparison);
    }

    /**
     * Filter the query on the size column
     *
     * Example usage:
     * <code>
     * $query->filterBySize(1234); // WHERE size = 1234
     * $query->filterBySize(array(12, 34)); // WHERE size IN (12, 34)
     * $query->filterBySize(array('min' => 12)); // WHERE size > 12
     * </code>
     *
     * @param     mixed $size The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function filterBySize($size = null, $comparison = null)
    {
        if (is_array($size)) {
            $useMinMax = false;
            if (isset($size['min'])) {
                $this->addUsingAlias(UserPulpitPeer::SIZE, $size['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($size['max'])) {
                $this->addUsingAlias(UserPulpitPeer::SIZE, $size['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(UserPulpitPeer::SIZE, $size, $comparison);
    }

    /**
     * Filter the query on the db_order column
     *
     * Example usage:
     * <code>
     * $query->filterByDbOrder(1234); // WHERE db_order = 1234
     * $query->filterByDbOrder(array(12, 34)); // WHERE db_order IN (12, 34)
     * $query->filterByDbOrder(array('min' => 12)); // WHERE db_order > 12
     * </code>
     *
     * @param     mixed $dbOrder The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function filterByDbOrder($dbOrder = null, $comparison = null)
    {
        if (is_array($dbOrder)) {
            $useMinMax = false;
            if (isset($dbOrder['min'])) {
                $this->addUsingAlias(UserPulpitPeer::DB_ORDER, $dbOrder['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($dbOrder['max'])) {
                $this->addUsingAlias(UserPulpitPeer::DB_ORDER, $dbOrder['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(UserPulpitPeer::DB_ORDER, $dbOrder, $comparison);
    }

    /**
     * Filter the query on the bg_filename column
     *
     * Example usage:
     * <code>
     * $query->filterByBgFilename('fooValue');   // WHERE bg_filename = 'fooValue'
     * $query->filterByBgFilename('%fooValue%'); // WHERE bg_filename LIKE '%fooValue%'
     * </code>
     *
     * @param     string $bgFilename The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function filterByBgFilename($bgFilename = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($bgFilename)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $bgFilename)) {
                $bgFilename = str_replace('*', '%', $bgFilename);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(UserPulpitPeer::BG_FILENAME, $bgFilename, $comparison);
    }

    /**
     * Filter the query on the visible column
     *
     * Example usage:
     * <code>
     * $query->filterByVisible(1234); // WHERE visible = 1234
     * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
     * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
     * </code>
     *
     * @param     mixed $visible The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function filterByVisible($visible = null, $comparison = null)
    {
        if (is_array($visible)) {
            $useMinMax = false;
            if (isset($visible['min'])) {
                $this->addUsingAlias(UserPulpitPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($visible['max'])) {
                $this->addUsingAlias(UserPulpitPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(UserPulpitPeer::VISIBLE, $visible, $comparison);
    }

    /**
     * Filter the query on the last_modified column
     *
     * Example usage:
     * <code>
     * $query->filterByLastModified('2011-03-14'); // WHERE last_modified = '2011-03-14'
     * $query->filterByLastModified('now'); // WHERE last_modified = '2011-03-14'
     * $query->filterByLastModified(array('max' => 'yesterday')); // WHERE last_modified > '2011-03-13'
     * </code>
     *
     * @param     mixed $lastModified The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function filterByLastModified($lastModified = null, $comparison = null)
    {
        if (is_array($lastModified)) {
            $useMinMax = false;
            if (isset($lastModified['min'])) {
                $this->addUsingAlias(UserPulpitPeer::LAST_MODIFIED, $lastModified['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($lastModified['max'])) {
                $this->addUsingAlias(UserPulpitPeer::LAST_MODIFIED, $lastModified['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(UserPulpitPeer::LAST_MODIFIED, $lastModified, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(UserPulpitPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(UserPulpitPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(UserPulpitPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query by a related Applications object
     *
     * @param   Applications|PropelObjectCollection $applications The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   UserPulpitQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByApplications($applications, $comparison = null)
    {
        if ($applications instanceof Applications) {
            return $this
                ->addUsingAlias(UserPulpitPeer::APPLICATION_ID, $applications->getId(), $comparison);
        } elseif ($applications instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(UserPulpitPeer::APPLICATION_ID, $applications->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByApplications() only accepts arguments of type Applications or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Applications relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function joinApplications($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Applications');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Applications');
        }

        return $this;
    }

    /**
     * Use the Applications relation Applications object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   ApplicationsQuery A secondary query class using the current class as primary query
     */
    public function useApplicationsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinApplications($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Applications', 'ApplicationsQuery');
    }

    /**
     * Filter the query by a related Users object
     *
     * @param   Users|PropelObjectCollection $users The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   UserPulpitQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByUsers($users, $comparison = null)
    {
        if ($users instanceof Users) {
            return $this
                ->addUsingAlias(UserPulpitPeer::USER_ID, $users->getId(), $comparison);
        } elseif ($users instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(UserPulpitPeer::USER_ID, $users->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByUsers() only accepts arguments of type Users or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Users relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function joinUsers($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Users');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Users');
        }

        return $this;
    }

    /**
     * Use the Users relation Users object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   UsersQuery A secondary query class using the current class as primary query
     */
    public function useUsersQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinUsers($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Users', 'UsersQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   UserPulpit $userPulpit Object to remove from the list of results
     *
     * @return UserPulpitQuery The current query, for fluid interface
     */
    public function prune($userPulpit = null)
    {
        if ($userPulpit) {
            $this->addCond('pruneCond0', $this->getAliasedColName(UserPulpitPeer::USER_ID), $userPulpit->getUserId(), Criteria::NOT_EQUAL);
            $this->addCond('pruneCond1', $this->getAliasedColName(UserPulpitPeer::APPLICATION_ID), $userPulpit->getApplicationId(), Criteria::NOT_EQUAL);
            $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
        }

        return $this;
    }

}
